package com.peanut.utils;

import org.neo4j.driver.AuthTokens;
import org.neo4j.driver.Driver;
import org.neo4j.driver.GraphDatabase;
import org.neo4j.driver.Session;

/****
 author:yifan
 date:2016
 description:
 **/
public class Neo4jUtil {

    private static Driver driver;
    private static Session session;

    public static Session getNeo4jSession() {
        if (session == null) {
            driver = GraphDatabase.driver("bolt://localhost:7687", AuthTokens.basic("neo4j", "123456"));
            session = driver.session();
        }
        return session;
    }

    public static void close() {
        session.close();
        driver.close();
    }

}
